var statusStore = Ext.create('Ext.data.Store',{
			  fields : ['value', 'text'],
			  data : [
			          ['0', '启用']
			          ,
			          ['1', '禁用']
			        ],
			        id:'0'

			});
Ext.define('DCApp.view.user.Detail', {
    extend: 'DCApp.view.Detail',
    alias: 'widget.Userdetail',
    
    bind: {
        title: '用户 - 【{theObj.id}】'
    },
    
    componentCls: 'user-detail',
    bodyPadding: 0,
    
    controller: 'detail',
    
    afterRender: function(ct, position) {
    	this.callParent();
    },
    items: [{
    	title: 'Panel 0',
        //flex: 2,
        frame: false,
        xtype: 'container',
        //layout: 'anchor',
        style: {
            overflow: 'auto'
        },

items: [
	{
		//title : '用户信息',
		margin : '0 0 10 0',
		//cls : 'nav_pos',
		reference : 'form',
		bodyPadding : 10,
		fieldDefaults : {
			labelAlign : 'right',
			labelWidth : 100,
			padding : 3
		},
		defaults : {
			anchor : '100%'
		},
		xtype: 'form',        
        items: [{
	xtype: 'fieldset',
	layout: 'hbox',
	cls : 'nav_pos',
	height: 400,
	title:'tab1',
	defaultType: 'textfield',
	items:[
	{
	//flex: 1,
	fieldLabel: '登陆用户名',
	bind: '{theObj.loginName}',
	allowBlank: false,
	//远端重复验证
	validator:function(val,fld){
		var fld = this;
		if(!val || val==''){
			fld.markInvalid("该输入项为必输项");
			return false;
		}
		
		Ext.Ajax.request({  
            params:{pn:'loginName',pv:val},  
            method:"GET",  
            //async:false,
            url:'/exists/User',  
            success:function(response,options){  
                if(response.responseText=='true'){//服务器端的返回值为'false'  
                	fld.markInvalid("该用户名已经被占用!");
                    return false;
                }else{
                	fld.clearInvalid();
                	return true;
                }
            }  
        }); 
		return true;
	}
	},	{
	//flex: 1,
	fieldLabel: '姓名',
	bind: '{theObj.name}',
	allowBlank: false
	}	]
},
{
	xtype: 'fieldset',
	layout: 'hbox',
	cls : 'nav_pos',
	title:'tab2',
	height:400,
	defaultType: 'textfield',
	items:[{
		//flex: 1,
		fieldLabel: '明文密码',
		bind: '{theObj.plainPassword}'
		},	
		{
	//flex: 1,
	fieldLabel: '密码',
	xtype:'displayfield',
	bind: '{theObj.password}',
	allowBlank: false 
	}]
},
{
	xtype: 'fieldset',
	layout: 'hbox',
	cls : 'nav_pos',
	title:'tab3',
	height:400,
	defaultType: 'textfield',
	items:[
	   	{
			//flex: 1,
			fieldLabel: '角色',
			bind: '{theObj.roles}',
			allowBlank: false,
			blankText: '该选项必选项',
		    xtype: 'combobox',
		    triggerAction:'all',
		    typeAhead :false,
		    editable:false,
		   	minChars:1,
		   	lazyInit:false,
		    queryParam : 'kw',
		    valueField: 'name',
		    displayField: 'name',
		    store: DCApp.Cfg.getDistinctStore('net.bat.entity.User','roles')
		},	/*{
		//flex: 1,
		fieldLabel: 'salt',
		xtype:'displayfield',
		bind: '{theObj.salt}'
		}*/
		{
		//flex: 1,
		fieldLabel: '最近登陆时间',
		xtype:'displayfield',
		renderer: Ext.util.Format.dateRenderer('m/d/Y'),
		bind: '{theObj.dt_lastlogin}'
	}]
},
{
	xtype: 'fieldset',
	layout: 'hbox',
	cls : 'nav_pos',
	title:'tab4',
	height:1200,
	defaultType: 'textfield',
	items:[
	{
	//flex: 1,
	fieldLabel: '注册时间',
	xtype:'displayfield',
	renderer: Ext.util.Format.dateRenderer('m/d/Y'),
	bind: '{theObj.registerDate}'
	},{
		//flex: 1,
		fieldLabel: '邮箱',
		vtype : "email",// email格式验证
		vtypeText : "不是有效的邮箱地址",// 错误提示信息
		allowBlank : false,
		//blankText: '邮箱不能为空',
		bind: '{theObj.email}'
		}	]
},	{
	xtype: 'fieldset',
	layout: 'hbox',
	cls : 'nav_pos',
	title:'tab5',
	height:400,
	defaultType: 'textfield',
	items:[
	{
	//flex: 1,
	fieldLabel: '状态',
	allowBlank: false,
    xtype: 'combobox',
    typeAhead :false,
    editable:false,
    triggerAction:'all',
   	minChars:1,
   	lazyInit:false,
    queryParam : 'kw',
    valueField: 'value',
    displayField: 'text',
	store:statusStore,
	bind: '{theObj.status}'
	}]
}/*,
{
	xtype: 'container',
	layout: 'hbox',
	defaultType: 'textfield',
	items:[
	{
	//flex: 1,
	fieldLabel: 'dt_lastlogin',
	bind: '{theObj.dt_lastlogin}'
	}	]
}*/]}]


    }],
    initComponent: function() {   
    	var rec = this.getViewModel().get('theObj');
		var item = this.items[0].items[0].items[0].items[0];
    	//修改user，非add
    	if(rec.get('id')>0){
    		item.xtype='displayfield';
    	}else{
    		item.xtype='textfield';
    	}
        this.callParent(arguments);
    }
});



